package nckd.wnqjt.tmc.tda.plugin.form;

import kd.bos.bill.BillShowParameter;
import kd.bos.form.FormShowParameter;
import kd.bos.form.ShowType;
import kd.bos.form.control.EntryGrid;
import kd.bos.form.events.HyperLinkClickEvent;
import kd.bos.form.events.HyperLinkClickListener;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.sdk.plugin.Plugin;

import java.util.EventObject;
import java.util.HashMap;
import java.util.Map;

/**
 * 动态表单插件
 */
public class FunddailyreportEditPlugin extends AbstractFormPlugin implements HyperLinkClickListener {

    @Override
    public void registerListener(EventObject e) {
        super.registerListener(e);
        // 监听分录行
        EntryGrid entryGrid = this.getView().getControl("entryentity");
        entryGrid.addHyperClickListener(this);
    }

    @Override
    public void hyperLinkClick(HyperLinkClickEvent hyperLinkClickEvent) {
        String fieldName = hyperLinkClickEvent.getFieldName();
        // 获取点击分录行的下标
        int rowIndex = hyperLinkClickEvent.getRowIndex();
        try {
            if("nckd_funddaybillno".equals(fieldName)){
                // 获取超链接信息 单据id
                Object funddaybillid = this.getModel().getValue("nckd_funddaybillid", rowIndex);
                Object billno = this.getModel().getValue("billno", rowIndex);
                BillShowParameter billshowparameter = new BillShowParameter();
                billshowparameter.setPkId(funddaybillid);
                billshowparameter.setFormId("nckd_funddaybill");
                billshowparameter.getOpenStyle().setShowType(ShowType.Modal);
                this.getView().showForm(billshowparameter);
            }
        }catch (Exception e) {
            System.out.println(e.getMessage());
        }

    }
}